define(function(require, exports, module){
	
	/**
     * @name popPosition
     * @class 封装素材预览html。
     */
	var swfobject = require('swfobject'),
    	contentTmpl = ['<div id="materialercontent">',
                   '<h1>亲，正在加载素材，请稍等！<br><span>如未加载成功，你可能需要较新版本的 Adobe Flash Player 哦！</span></h1>',
                   '<p><a href="http://www.adobe.com/go/getflashplayer" target="_blank"><img src="/static/trp/images/get_flash_player.gif" alt="Get Adobe Flash player" title="去 Adobe 官网获取 Flash 播放器" /></a></p>',
                   '</div>'
               ].join(''),
	
    initHtml = function(option){
		var op = $.extend({
				item: '',
				data: {
					name: 'hhh.jpg', 
					url:'http://127.0.0.1:8090/static/trp/images/chart.jpg', 
					height: 200, 
					width: 200, 
					type: '5L', 
					size: 7153
				},
				clas: 'pic'
			}, option);
		
		var $item = typeof op.item=='string'?$(op.item):op.item;
		if(semi.utils.isEmpty($item) || semi.utils.isEmpty(op.data.url))return;
		
		var width = parseInt((op.data.width+'').replace('px','')),
			height = parseInt((op.data.height+'').replace('px',''))
			suffix = op.data.url.substr(op.data.url.length-4,4);
		
		$('#semiMaterialer, .showmaterial',$item).remove();
		if(suffix=='.swf'){
		    var defaultVars = {}
		    var defaultParams = {
		        menu: 'false',
		        quality: 'high',
		        wmode: 'opaque',
		        allowFullScreen: 'true',
		        allowScriptAccess: 'always'
		    }
		    var defaultAttrs = {
		        id: 'semiMaterialer',
		        name: 'semiMaterialer'
		    }
			$item.append('<a href="'+op.data.landingpage.toUrl()+'" target="_blank" class="showmaterial" style="width:'+width+'px;height:'+height+'px;position:absolute;z-index:10;">'+contentTmpl+'</a>').css('position','relative');
			swfobject.embedSWF(op.data.url, 'materialercontent', width, height, '10.0.0', swfobject.installUrl, defaultVars, defaultParams, defaultAttrs);
		}else if(suffix=='.jpg' || suffix=='.bmp' || suffix=='.gif' || suffix=='.png'){
			if(semi.utils.isEmpty(op.data.landingpage)){
				$item.append('<img class="showmaterial '+op.clas+'" src="'+op.data.url+'" width="'+width+'" height="'+height+'">');
			}else{
				$item.append('<a href="'+op.data.landingpage.toUrl()+'" target="_blank"><img class="showmaterial '+op.clas+'" src="'+op.data.url+'" width="'+width+'" height="'+height+'"></a>');
			}
		}else{
			$item.append('<span class="showmaterial red">素材格式并非 jpg/bmp/gif/png/swf，请检查！</span>');
		}
	}
	
	return{
		init: initHtml
	}
});